﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:SQ816FWUpdater"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="SQ816FWUpdater.MainWindow"
        Title="Mattson SQ816 Sequencer Firmware Updater"
        ResizeMode="CanResize"
        DataContext="{Binding RelativeSource={RelativeSource Self}}" MinWidth="550" MinHeight="250" d:DesignWidth="550" d:DesignHeight="250">
    <Window.Resources>
        <local:VisConverter x:Key="VisToBool"/>
        <local:NotVisConverter x:Key="NotVisConverter"/>
        <Style TargetType="{x:Type Button}">
            <Setter Property="Margin" Value="5"/>
            <Setter Property="Padding" Value="5,1"/>
        </Style>
        <Style TargetType="{x:Type Label}">
            <Setter Property="HorizontalAlignment" Value="Right"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
    </Window.Resources>
    <DockPanel>
        <Grid DockPanel.Dock="Top">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Label Grid.Row="0" Grid.Column="0" Content="Device Status:"/>
            <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Status, Mode=OneWay}"/>
            <Button Grid.Row="0" Grid.Column="2" Command="{Binding RedetectCmd}" Content="Redetect Device"/>
            <TextBlock Grid.Row="2" Grid.Column="1" Text="File doesn't exist" Foreground="Red" Visibility="{Binding IsFilenameValid, Converter={StaticResource NotVisConverter}}" HorizontalAlignment="Center" Margin="91,6.4,92.4,6.4"/>
            <Label Grid.Row="1" Grid.Column="0" Content="Please select the firmware file:" Target="{Binding ElementName=theFile}"/>
            <DockPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2">
                <Button DockPanel.Dock="Right" Command="{Binding PickFolderCmd}" Content="_..."/>
                <TextBox Margin="0,5" x:Name="theFile" Text="{Binding Filename, Mode=TwoWay}"/>
            </DockPanel>
            <Button Grid.Row="2" Grid.Column="2"  Command="{Binding FlashCmd}" Content="Flash!" IsEnabled="{Binding ReadyForFlashing, Mode=OneWay}"/>
            <Button Grid.Row="2" Grid.Column="0" Content="{Binding ExpandoText}" Command="{Binding ExpandoCmd}" HorizontalAlignment="Left" Width="100"/>
        </Grid>
        <ProgressBar DockPanel.Dock="Bottom" Height="5" Minimum="0" Maximum="100" Value="{Binding Percent}"/>
        <GroupBox Header="Firmware Updater Details" Visibility="{Binding IsExpanded,Converter={StaticResource VisToBool}}">
            <TextBox IsReadOnly="True" Text="{Binding ToolOutput, Mode=OneWay}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/>
        </GroupBox>
    </DockPanel>
</Window>
